<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="edge"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telphone=no, email=no"/>
    <meta name="renderer" content="webkit"/>
    <meta name="HandheldFriendly" content="true"/>
    <meta name="MobileOptimized" content="320"/>
    <meta name="screen-orientation" content="portrait"/>
    <meta name="x5-orientation" content="portrait"/>
    <meta name="full-screen" content="yes"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="browsermode" content="application"/>
    <meta name="x5-page-mode" content="app"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <meta content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"/>
    <link rel="stylesheet" type="text/css" href="/resources/frontcss/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="/resources/frontcss/Hui.css" />
    <link rel="stylesheet" type="text/css" href="/resources/frontcss/aui/common.css" />
    <title>荩美国际商城</title>
    <style>
        .top-cot{ width:100%; height:2.2rem; line-height:2.2rem; background:#28163d; color:#fff; text-align:center; font-size:16px;}
        .button{
            float:right;
            width:105px;
            height:45px;
            background: #bf2072;
            text-align: center;
            border: none;
            color:#fff;
            font-size:16px;
            font-weight: bold;
        }
    </style>
    <style type="text/css">
        .aui-list-view-cell:active {
            background: #FFFFFF;
        }
        .aui-right {
            color: #999;
            font-size: 14px;
            margin-right: 18px;
            line-height: 26px
        }
        .payclass .aui-input-row .aui-input-addon {
            font-size: 16px;
            font-weight: 400;
            line-height: 1;
            color: #000;
            text-align: center;
            display: table-cell;
            width: 1%;
            white-space: nowrap;
            vertical-align: middle;
            padding: 0px;
        }
        .payclass .aui-input {
            text-align: right;
            margin-right: 15px;
        }
        .payclass .aui-input-row:first-child:after {
            border-top: 0px solid #e2e2e2;
        }
        .aui-counter-box {
            width: 100%;
            line-height: 15px;
            height: 30px;
            font-size: 14px;
            font-weight: 500
        }
        .aui-list-view-cell:after {
            border-bottom: 1px solid #f4f4f4;
            width: 90%;
            float: right;
        }
        .order {
            background: #ffffff;
        }
        .order-info {
            font-size: 0.875em;
            width: 100%;
        }
        .order-info span {
            color: #333;
            margin-right: 5px;
        }
        .order-info time {
            color: #999999;
            font-size: 0.75em;
        }
        .order-info i.aui-iconfont {
            color: #999;
            font-size: 0.875em;
        }
        .order-icon img {
            width: 80%;
            border-radius: 5px;
        }
        .order-title {
            font-size: 1em;
            color: #333;
            padding-bottom: 10px;
            margin-bottom: 10px;
        }
        .order-title > i.aui-iconfont {
            font-size: 14px;
            color: #999999;
        }
        p.goods-list {
            font-size: 14px;
            color: #999;
            margin-bottom: 4px;
        }
        p.count-info {
            font-size: 14px;
            color: #999;
            padding-bottom: 3px;
        }
        p.count-info span {
            margin: 0 3px;
        }
        p.count-info strong {
            color: #666;
            font-size: 16px;
            font-weight: 700;
        }
        .btn {
            /*margin: 5px;*/
        }
        .btn .aui-btn {
            font-size: 0.75em;
        }
        .btn .aui-btn:first-child {
            margin-right: 10px;
        }
        .aui-border-b:after {
            border-color: #ddd;
        }
        .afterborder:after {
            border-bottom: none !important;
        }
        .afterborder {
            border-top: 1px solid #f4f4f4;
        }
        .aui-tips-content {
            line-height: 45px;
            height: 45px;
            padding-left: 10px;
            padding-right: 10px;
        }
        .aui-list-view {
            line-height: 30px;
        }
        .aui-list-view i.iconfont {
            padding: 5px;
            border-radius: 4px;
            margin-right: 10px;
            color: #ffffff;
            font-size: 1.125em;
        }
        .aui-list-view .aui-img-object {
            max-width: 30px;
            height: 30px;
            line-height: 30px;
        }
        .aui-radio {
            margin: 0;
        }
        .aui-btn-ff9800 {
            background: #ff9800;
            color: #fff;
            padding: 8px 40px;
        }
        .aui-content {
            margin-bottom: 0 !important
        }
        .aui-list-view-cell:last-child:after {
            border: none
        }
        .aui-counter-box {
            width: 100%;
            padding: 0;
            line-height: 26px;
        }
        .aui-list-view .aui-img-object {
            max-width: 70px;
            height: 70px;
            line-height: 70px;
        }
        .aui-list-view-cell:last-child:after {
            left: 0;
        }
        .aui-list-view-cell:after {
            left: 15px;
        }
        .aui-list-view-cell:active {
            background: #fff;
        }
        .aui-nav .aui-bar-tab {
            background: #34495E;
        }
        .aui-nav .aui-bar-tab li .aui-iconfont, .aui-nav .aui-bar-tab li p {
            color: #fff;
        }
        .aui-nav .aui-bar-tab li.active .aui-iconfont, .aui-nav .aui-bar-tab li.active p {
            color: #14bd7c;
        }
        .aui-nav {
            background: #fff;
            font-size: 18px;
            color: #fff;
            text-align: center;
        }
        .aui-nav div {
            height: 55px;
        }
        .aui-nav .buy {
            line-height: 55px;
        }
        .blue {
            background: #fff;
        }
        .blue .aui-iconfont, .blue p {
            color: #999;
        }
        .buy {
            background: #FF9800;
        }
        .aui-input-row:first-child:after {
            border-top: 0px solid #c8c7cc;
        }
        .aui-input-row .aui-input-addon {
            width: auto;
        }
        .aui-input-row:last-child:after {
            border-bottom: 0px solid #000;
        }
        .heji {
            font-size: 14px;
            vertical-align: middle;
            white-space: nowrap;
            line-height: 55px;
        }
        .shopcar {
            font-size: 20px;
            margin-left: 20px;
        }
        .xsgdnoborder:after {
            border: none
        }
    </style>

    <script type="text/javascript" src="/resources/js/jquery-1.8.1.min.js"></script>
</head>
<body style="overflow-x:hidden;">
<div class="top-cot">升级中心</div>

        <div id="step1">
        <c:choose>
            <c:when test="${user.type eq 'General' and user.isPartner eq '1' and user.userLevel eq '0'}">
                <p style="text-align: center;font-size: 18px;">您当前已经是省级合伙人</p>
            </c:when>
             <c:otherwise>

            <div class="H-flexbox-horizontal  H-border-vertical-bottom-after">
                <div class="H-flex-item H-padding-10">
                    <div class="H-font-size-18 H-theme-font-color-999 H-text-show-row-2 H-margin-vertical-top-2">
                        请选择要申请的代理商级别
                    </div>
                </div>
            </div>

            <div class="payclass aui-content" style="color:#818181;font-size: 14px !important">
                <ul class="aui-list-view aui-in">
                    <c:if test="${user.type eq 'Customer'}">
                    <li class="aui-list-view-cell aui-img">
                        金牌代理
                        <div class="aui-pull-right">
                            <input value="Gold" checked class="H-border-radius-circle aui-radio aui-radio-danger" type="radio" name="type" id="type0" onclick="showZc()">
                        </div>
                    </li>
                    </c:if>
                    <c:if test="${user.type eq 'Customer' or user.type eq 'Gold'}">
                    <li class="aui-list-view-cell aui-img">
                        全国总代理
                        <div class="aui-pull-right">
                            <input value="General" checked class="H-border-radius-circle aui-radio aui-radio-danger" type="radio" name="type" id="type1" onclick="showZc()">
                        </div>
                    </li>
                    </c:if>
                    <c:if test="${user.type ne 'General' or (user.type eq 'General' and user.isPartner ne '1') or (user.type eq 'General' and user.isPartner eq '1' and user.userLevel ne '0')}">
                    <li class="aui-list-view-cell aui-img">
                        区域合伙人
                        <div class="aui-pull-right">
                            <input value="Partner" checked class="H-border-radius-circle aui-radio aui-radio-danger" type="radio" name="type" id="type2" onclick="showZc()">
                        </div>
                    </li>
                    </c:if>
                </ul>
            </div>

            <div class="payclass aui-content" style="color:#818181;font-size: 14px !important">
                <ul class="aui-list-view aui-in">
                        <li class="aui-list-view-cell aui-img" id="jpzc" style="display: none;">
                            金牌代理:<br>
                            1.一次性投资1000元，公司送价值1192元产品，申请成为公司金牌代理商。<br>
                            2.开通后台，与公司共享客户信息。<br>
                            3.每开发消费者购买一份49.9元的产品，即可拿7元红包，非三级4元红包（秒到账）。<br>
                            4.介绍一名金牌代理商，公司奖励100元，并下拿三级。<br>
                            5.介绍一名全国总代，公司奖励1000元。<br>
                        </li>
                        <li class="aui-list-view-cell aui-img" id="zdzc" style="display: none;">
                            全国总代理:<br>
                            1、开通后台ID，与总部一起共享客户信息。<br>
                            2、每推广一名49.9元公司奖励10元红包，非三代5元红包（秒到账）。<br>
                            3、推广价（限名额）10000元。<br>
                            4、赠送价值10000元的荩美佳紫桂茶（限名额）<br>
                            5、旗下每增加一位金牌代理商，公司奖励100元，并拿金牌代理商推广49.9元的三代内4元，非三代1元。<br>
                            6、每介绍一名全国总代，公司奖励1000元，下拿三级，总代两级内每上一个金牌代理商公司奖励100元。<br>
                        </li>
                        <li class="aui-list-view-cell aui-img" id="qyzc" style="display: none;">
                            区域合伙人:<br>
                            1、合伙人分为三个级别，分别为：县区级合伙人、市级合伙人和省级合伙人，在你所管辖区域一年内得所有业绩总额，公司给3%的管理费。<br>
                            2、开通后台ID，与总部共享客户信息。<br>
                            3、送一个价值10000元的总代名额。<br>
                            4、县区级推广价（限名额）30000元。赠送价值同等金额的荩美佳紫桂茶（限名额）<br>
                        </li>
                </ul>
            </div>

            <label style="margin-bottom: 5px;height: 30px;padding-left: 5px;">
                <button  onclick="nextStep(2)" class="button">下一步</button>
            </label>
        </div>

        <div id="step2" style="display: none;">

            <div class="H-flexbox-horizontal  H-border-vertical-bottom-after">
                <div class="H-flex-item H-padding-10">
                    <div class="H-font-size-18 H-theme-font-color-999 H-text-show-row-2 H-margin-vertical-top-2">
                        请选择代理区域
                    </div>
                </div>
            </div>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;display: none;" id="level">
                代理级别：
                <select id="userLevel" name="userLevel" onchange="showCitys()">
                    <option value="0">省级</option>
                    <option value="1">副省级</option>
                    <option value="2">地市</option>
                    <option value="3">区县</option>
                </select>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important" id="province_label" >
                省份：
                <select id="province" name="province" onchange="loadCity('province','city')">

                  </select>
                <input type="hidden" name="provinceName" id="provinceName"/>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important" id="city_label" >
                地市：
                <select id="city" name="city" onchange="loadArea('city','area')">
                </select>
                <input type="hidden" name="cityName" id="cityName"/>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important" id="area_label" >
                区县：
                <select id="area" name="area">
                </select>
                <input type="hidden" name="areaName" id="areaName"/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important" >

                <button  onclick="checkExist()"  class="button">下一步</button>
                <button  onclick="nextStep(1)"  class="button"  style="background: #EEB422;">上一步</button>
            </li>
        </div>

        <div id="step3" style="display: none;">
            <div class="H-flexbox-horizontal  H-border-vertical-bottom-after">
                <div class="H-flex-item H-padding-10">
                    <div class="H-font-size-18 H-theme-font-color-999 H-text-show-row-2 H-margin-vertical-top-2">
                        请确认收货信息
                    </div>
                </div>
            </div>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <input type="text" name="userName" id="userName" value="${userAddress.userName}" maxlength="20" placeholder="请输入联系人名称" <c:if test="${not empty userAddress.userName}">readonly</c:if>/>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <input type="text" name="telephone" id="telephone" value="${userAddress.telephone}" maxlength="20" placeholder="请输入联系电话" <c:if test="${not empty userAddress.telephone}">readonly</c:if>/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
               <input type="text" name="idCard" id="idCard" value="${user.idCard}" placeholder="请输入身份证号" maxlength="20" <c:if test="${not empty user.idCard}">readonly</c:if>/>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <input type="text" name="bankName" id="bankName" value="${user.bankName}" placeholder="请输入银行名称" maxlength="20" <c:if test="${not empty user.bankName}">readonly</c:if>/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
               <input type="text" name="cardName" id="cardName" value="${user.cardName}" placeholder="请输入持卡人名称" maxlength="20" <c:if test="${not empty user.cardName}">readonly</c:if>/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <input type="text" name="cardNo" id="cardNo" value="${user.cardNo}" placeholder="请输入银行卡号"  maxlength="30" <c:if test="${not empty user.cardNo}">readonly</c:if>/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                所在省份：
                <select id="addressProvince" name="addressProvince" onchange="loadCity('addressProvince','addressCity')">

                </select>
                <input type="hidden" name="addressProvinceName" id="addressProvinceName"/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                所在地市：
                <select id="addressCity" name="addressCity" onchange="loadArea('addressCity','addressArea')">

                </select>
                <input type="hidden" name="addressCityName" id="addressCityName"/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                所在区县：
                <select id="addressArea" name="addressArea">

                </select>
                <input type="hidden" name="addressAreaName" id="addressAreaName"/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <input type="text" name="address" id="address" value="${userAddress.address}" placeholder="请输入收货地址"  maxlength="50"/>
            </li>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <button  onclick="nextStep(4)"  class="button">下一步</button>
                <button  onclick="nextStep(2)"  class="button" style="background: #EEB422;">上一步</button>
            </li>
        </div>

        <div id="step4" style="display: none;">
            <div class="H-flexbox-horizontal  H-border-vertical-bottom-after">
                <div class="H-flex-item H-padding-10">
                    <div class="H-font-size-18 H-theme-font-color-999 H-text-show-row-2 H-margin-vertical-top-2">
                        代理升级确认
                    </div>
                </div>
            </div>
            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
               <span id="applyType"></span>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <span id="applyUser"></span>
                <span id="applyTelephone"></span>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <span id="applyArea"></span>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <span  style="color: #bf2072;">合计：</span>
                <span id="totalMoney" style="color: #bf2072;font-weight: bold;font-size:26px;"></span>
            </li>

            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <div class="H-flex-item H-font-size-16">
                    <input type="checkbox" name="isUse" id="isUse"  checked onclick="changeAmount()"
                           class="H-checkbox H-checkbox-null H-display-block H-vertical-align-middle H-font-size-16 H-theme-font-color4 H-border-radius-circle H-margin-horizontal-right-10 H-float-left">
                    可使用余额：<span id="bonus">${money}</span>元
                </div>
                <input type="hidden" name="amount" id="amount" value="1"/>
            </li>


            <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
                <button  onclick="submit()"  class="button">确定</button>
                <button  onclick="nextStep(3)"  class="button"  style="background: #EEB422;">上一步</button>
            </li>
        </div>

        <li class="afterborder aui-list-view-cell" style="color: #808080;font-size: 14px !important;" >
            <span id="bz"></span>
        </li>
        </c:otherwise>
        </c:choose>
    </div>
      <input type="hidden" id="hide_province" value="${province}"/>
       <input type="hidden" id="hide_city" value="${city}"/>
       <input type="hidden" id="hide_area" value="${area}"/>
<script type="text/javascript" src="/views/js/validate.js"></script>
<script type="text/javascript">
    function changeAmount(){
        var chk = $("#isUse").attr("checked");
        if(chk == "checked"){
            $("#amount").val("1");
        }else{
            $("#amount").val("0");
        }
    }
    function showCitys(){
        var userLevel = $("#userLevel").val();
        if(userLevel=="0"){
            $("#province_label").show();
            $("#city_label").hide();
            $("#area_label").hide();
        }else if(userLevel=="1"){
            $("#province_label").show();
            $("#city_label").show();
            $("#area_label").hide();
        }else if(userLevel=="2"){
            $("#province_label").show();
            $("#city_label").show();
            $("#area_label").hide();
        }else if(userLevel=="3"){
            $("#province_label").show();
            $("#city_label").show();
            $("#area_label").show();
        }

    }

    function checkExist(){
        var type = $("input:radio[name='type']:checked").val();
        if(type=='Partner'){
            $.ajax({
                url:"/front/user/checkQydl?r="+Math.random(),
                type:"post",
                data:{
                    userLevel:$("#userLevel").val(),
                    province:$("#province").val(),
                    city:$("#city").val(),
                    area:$("#area").val()
                },
                success:function(res){
                    if(res.success){
                        nextStep(3);
                    }else{
                        alert(res.msg);
                    }
                },
                error:function(){

                }
            })
        }else{
            nextStep(3);
        }

    }

    function nextStep(i){
        if(i==4){
            var userName = $("#userName").val();
            if(userName==""){
                alert("请输入联系人名称！");
                return ;
            }
            var telephone = $("#telephone").val();
            if(telephone==""){
                alert("请输入联系电话！");
                return ;
            }
            var idCard = $("#idCard").val();
            if(idCard==""){
                alert("请输入身份证！");
                return ;
            }
           /* if(!isCardNo(idCard)){
                alert("请输入有效身份证号！");
                return ;
            }*/
            var bankName = $("#bankName").val();
            if(bankName==""){
                alert("请输入银行名称！");
                return ;
            }
            var cardName = $("#cardName").val();
            if(cardName==""){
                alert("请输入持卡人名称！");
                return ;
            }
            var cardNo = $("#cardNo").val();
            if(cardNo==""){
                alert("请输入银行卡号！");
                return ;
            }
            var address = $("#address").val();
            if(address==""){
                alert("请输入收货地址！");
                return ;
            }
        }
        for(var a=0;a<5;a++){
            $("#step"+a).hide();
        }
        $("#step"+i).show();
        if(i==2){
            var type = $("input:radio[name='type']:checked").val();
            if(type=='Partner'){
                $("#level").show();
                $("#province_label").show();
                $("#city_label").hide();
                $("#area_label").hide();
            }
        }
        if(i==4){
            $("#applyUser").html($("#userName").val());
            $("#applyTelephone").html($("#telephone").val());

            var type = $("input:radio[name='type']:checked").val();
            $("#applyArea").html($("#province").find("option:selected").text()+$("#city").find("option:selected").text()+$("#area").find("option:selected").text());
            var pindex = "0";
            if(type=='Gold'){
                $("#applyType").html("金牌代理申请");
                pindex = "0";
            }else if(type=='General'){
                $("#applyType").html("全国总代理申请");
                pindex = "1";
            }else if(type=='Partner'){
                pindex = "2";
                $("#applyType").html("区域合伙人申请");
                var userLevel = $("#userLevel").val();
                var html = "";
                if(userLevel=="0"){
                    html = "省级代理&nbsp;&nbsp;";
                    html += $("#province").find("option:selected").text();
                }else if(userLevel=="1"){
                    html = "副省级代理&nbsp;&nbsp;";
                    html += $("#province").find("option:selected").text()+$("#city").find("option:selected").text();
                }else if(userLevel=="2"){
                    html = "地市代理&nbsp;&nbsp;";
                    html += $("#province").find("option:selected").text()+$("#city").find("option:selected").text();
                }else if(userLevel=="3"){
                    html = "区县代理&nbsp;&nbsp;";
                    html += $("#province").find("option:selected").text()+$("#city").find("option:selected").text()+$("#area").find("option:selected").text();
                }
                $("#applyArea").html(html);
            }
            showRemark(pindex);
        }
    }


    function showRemark(i){
        $.ajax({
            url:"/wx/getUpdateConfig?r="+Math.random(),
            type:"post",
            data:{
                type:i
            },
            success:function(res){
                if(res.success){
                  $("#totalMoney").html(res.data);
                }else{
                  alert(res.msg);
                }
            },
            error:function(){}
        })
    }

    $(function(){
        loadProvince('addressProvince','addressCity','addressArea');
        loadProvince('province','city','area');
        showZc();
    });

    function showZc(){
        var type = $("input[name='type']:checked").val();
        if(type!=undefined){
            if(type=='Gold'){
                $("#jpzc").show();
                $("#zdzc").hide();
                $("#qyzc").hide();
            }else if(type=='General'){
                $("#jpzc").hide();
                $("#zdzc").show();
                $("#qyzc").hide();
            }else if(type=='Partner'){
                $("#jpzc").hide();
                $("#zdzc").hide();
                $("#qyzc").show();
            }
        }
    }


    function submit(){
        var type = $("input:radio[name='type']:checked").val();

        if(type==undefined||type=='undefined'||type==''){
            alert("请选择升级的角色！");
            return ;
        }
        if(type=="Partner"){
            var userLevel = $("#userLevel").val();
            if(userLevel=='0'){
                var province = $("#province").val();
                if(province==''){
                    alert("请选择要代理的省份！");
                    return ;
                }
            }
            if(userLevel=='1'){
                var city = $("#city").val();
                if(city==''){
                    alert("请选择要代理的副省级地市！");
                    return ;
                }
            }
            if(userLevel=='2'){
                var city = $("#city").val();
                if(city==''){
                    alert("请选择要代理的地市！");
                    return ;
                }
            }
            if(userLevel=='3'){
                var area = $("#area").val();
                if(area==''){
                    alert("请选择要代理的区县！");
                    return ;
                }
            }

        }else{
            var province = $("#province").val();
            if(province==''){
                alert("请选择要代理的省份！");
                return ;
            }
            var city = $("#city").val();
            if(city==''){
                alert("请选择要代理的地市！");
                return ;
            }

            var area = $("#area").val();
            if(area==''){
                alert("请选择要代理的区县！");
                return ;
            }
        }
        var address = $("#address").val();
        if(address==""){
            alert("请输入收货地址！");
            return ;
        }
        $("#provinceName").val($("#province").find("option:selected").text());
        $("#cityName").val($("#city").find("option:selected").text());
        $("#areaName").val($("#area").find("option:selected").text());
        $("#addressProvinceName").val($("#addressProvince").find("option:selected").text());
        $("#addressCityName").val($("#addressCity").find("option:selected").text());
        $("#addressAreaName").val($("#addressArea").find("option:selected").text());
        if(confirm("确定升级吗？"))
        $.ajax({
            url:"/front/user/update?r="+Math.random(),
            type:"post",
            data:{
                type:type,
                userName:$("#userName").val(),
                telephone:$("#telephone").val(),
                idCard:$("#idCard").val(),
                bankName:$("#bankName").val(),
                cardName:$("#cardName").val(),
                cardNo:$("#cardNo").val(),
                userLevel:$("#userLevel").val(),
                province:$("#province").val(),
                city:$("#city").val(),
                area:$("#area").val(),
                provinceName:$("#provinceName").val(),
                cityName:$("#cityName").val(),
                areaName:$("#areaName").val(),
                addressProvince:$("#addressProvince").val(),
                addressCity:$("#addressCity").val(),
                addressArea:$("#addressArea").val(),
                addressProvinceName:$("#addressProvinceName").val(),
                addressCityName:$("#addressCityName").val(),
                addressAreaName:$("#addressAreaName").val(),
                amount : $("#amount").val(),
                address:$("#address").val()
            },
            success:function(res){
                alert(res.msg);
                if(res.success){
                    if(type!='Partner'){
                        if(res.data!=null){
                            if(res.data.status=='Pay'){
                                window.location.href = "/front/user/main";
                            }else{
                                window.location.href = "/front/user/updatePay?orderId="+res.data.id;
                            }
                        }

                    }else{
                        window.location.href = "/front/user/main";
                    }
                }
            },
            error:function(){}
        })

    }

    function loadProvince(id,city,area){
        $.ajax({
            url:"/front/loadCitys?r="+Math.random(),
            type:"post",
            data:{
                pid:"0"
            },
            success:function(res){
                if(res.success){
                    fillSelect(id,res.data,$("#hide_province").val());
                    loadCity(id,city,area);
                }
            },
            error:function(){

            }
        })
    }
    function loadCity(province,city,area){
        $.ajax({
            url:"/front/loadCitys?r="+Math.random(),
            type:"post",
            data:{
                pid:$("#"+province).val()
            },
            success:function(res){
                if(res.success){
                    fillSelect(city,res.data,$("#hide_city").val());
                    loadArea(city,area);
                }
            },
            error:function(){

            }
        });
    }
    function loadArea(oid,id){
        $.ajax({
            url:"/front/loadCitys?r="+Math.random(),
            type:"post",
            data:{
                pid:$("#"+oid).val()
            },
            success:function(res){
                if(res.success){
                    fillSelect(id,res.data,$("#hide_area").val());
                }
            },
            error:function(){

            }
        });
    }
    function fillSelect(id,data,no){
        var html = "<option value=''>请选择</option>";
        $.each(data,function(i,n){
            var ckd = "";
            if(n.no==no){
                ckd = " selected"
            }
            html += "<option value='"+n.no+"' "+ckd+">"+n.name+"</option>";
        });
        $("#"+id).html(html);
    }
</script>
</body>
</html>